$(function () {
    var temp = JSON.parse(localStorage.getItem("gameNumber"));
    console.log(temp);
    for(var i=0;i<temp.length;i++){
        temp[i]={
            role:temp[i],
            isAlive:true,
            killdead:false,
            votedead:false,
            day:0
        };
    };
    //filter
    console.log(temp)
    var pageCheck=JSON.parse(localStorage.getItem('pageCheck'));
    var str = getQueryString("status");
    switch (str) {
        case 'kill':
            $('header span').eq(1).text('杀手杀人');
            $('.title').show().css('display','flex');
            break;
        case 'vote':
            $('header span').eq(1).text('全名投票');
            $('.title').show().css('display','flex');
            break;
    }
    for(var i=0;i<temp.length;i++){
        var box=$("<div></div>").html(`<div class="top">${temp[i].role}</div><div class="bottom">${[i+1]}号</div>`).addClass("orange")
        $('.wrapper').append(box)
    };
    $(".role").click(function () {
        window.location="task2-5.html"
    })

    function getQueryString(name) {
        var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
        if (result == null || result.length < 1) {
            return "";
        }
        return result[1];
    }
})